﻿@{
    ViewData["Title"] = "修改密码";
}

 
   

                            <div class="layui-form" lay-filter="" style="background-color:#fff;padding:5px;">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">当前密码</label>
                                    <div class="layui-input-inline">
                                        <input type="password" name="oldPassword" id="oldPassword" maxlength="12"  lay-verify="oldPassword" lay-vertype="tips" class="layui-input layui-form-danger">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">新密码</label>
                                    <div class="layui-input-inline">
                                        <input type="password" name="password" lay-verify="pass" lay-vertype="tips" maxlength="12" autocomplete="off" id="LAY_password" class="layui-input">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux">6到12个字符</div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">确认新密码</label>
                                    <div class="layui-input-inline">
                                        <input type="password" id="LAY_repassword" name="repassword" maxlength="12" lay-verify="repass" lay-vertype="tips" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-verify="setmypass" lay-submit="" lay-filter="setmypass">确认修改</button>
                                        
                                    </div>
                                </div>
                            </div> 

    <script>


   

        //监听提交
        form.on('submit(setmypass)', function (data) {
            doModify();
        });


 
         //操作修改密码
        function doModify() {
 
            //判断两次输入的密码是否一致
            var password = $("#LAY_password").val();
            var repassword = $("#LAY_repassword").val();
            var oldPassword = $("#oldPassword").val();
            if (password != repassword) {
                layer.msg("两次密码输入不一致！");
            } else {
                $.post("/ModifyPassword/doPassModify",
                    { "oldPassword": oldPassword, "password": password },
                    function (d) {
                        layer.msg(d.msg, function () {
                            if (d.code == 1) {
                                window.parent.layer.closeAll();
                            }
                        });
                        
                    });
            }

            
         
    }
        //自定义验证规则
form.verify({
    oldPassword: function (value) {
        if (value.length < 1) {
            return '当前密码不能为空';
        }
    },pass: [
        /^[\S]{6,12}$/
        , '新密码必须6到12位，且不能出现空格'
    ], repass: [
        /^[\S]{6,12}$/
        , '确认密码必须6到12位，且不能出现空格'
    ] 
 
  });
        form.render();
 
    </script>

